package user

import (
	"talent.com/agency_im/conf"
)

func init() {
	conf.InitConfig()
}

func Auth(token string) (*User, error) {

	var (
		u         *User
		err       error
		authToken *AuthToken
	)

	if authToken, err = GetAuthToken(token); err != nil {
		return nil, err
	}

	if u, err = GetUser(authToken.UserID); err != nil {
		return nil, err
	} else {
		//if !u.Status {
		//	return nil, errors.New(fmt.Sprintf("user is disable: %v", u.ID))
		//}
	}
	return u, nil
}
